<?php
/**
 * Created by PhpStorm.
 * User: fengyan
 * Date: 17-11-3
 * Time: 下午2:22
 */

namespace App\Models\Portal;


use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class Document extends Model
{
    use SoftDeletes;

    protected $table = 'portal_document';

    /**
     * 栏目
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function category()
    {
        return $this->belongsTo('\\App\\Models\\Portal\\Category', 'category_id', 'id');
    }

    /**
     * 资讯
     * @return \Illuminate\Database\Eloquent\Relations\HasOne
     */
    public function news()
    {
        return $this->hasOne('\\App\\Models\\Portal\\DocumentNews', 'id', 'id');
    }

    /**
     * 图集
     * @return \Illuminate\Database\Eloquent\Relations\HasOne
     */
    public function photo()
    {
        return $this->hasOne('\\App\\Models\\Portal\\DocumentPhoto', 'id', 'id');
    }

    /**
     * 图集
     * @return \Illuminate\Database\Eloquent\Relations\HasOne
     */
    public function page()
    {
        return $this->hasOne('\\App\\Models\\Portal\\DocumentPage', 'id', 'id');
    }

    /**
     * 封面图片
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function cover()
    {
        return $this->belongsTo('\\App\\Models\\Basic\\Resource', 'cover_id', 'id')->select(['resource_type', 'resource_name', 'resource_path']);
    }
}